<?php
class StatisticsGoogleWidget  extends CWidget{
    
	//输出字符串
	private $google = '';
    
    private $controller= '';
    
    private $action= '';

	public function init(){
        $this->controller = Yii::app()->controller->id;  
        $this->action = Yii::app()->controller->action->id; 
	}

	public function run(){
        $this->googleStatistics();
		echo $this->google;
	}

    public function googleStatistics(){
        $this->google = <<<GOOGLE
                <div style='display:none'>\n
                    <script type="text/javascript" language='javascript'>\n
                      var _gaq = _gaq || [];\n
                      _gaq.push(['_setAccount', 'UA-40032119-1']);\n
                      _gaq.push(['_trackPageview']);\n
                      var pluginUrl ='//www.google-analytics.com/plugins/ga/inpage_linkid.js';\n
                      _gaq.push(['_require', 'inpage_linkid', pluginUrl]);\n

                      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n
                      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n
                      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n
                      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n
                      
                      ga('create', 'UA-40032119-1', 'gowhich.com');\n
                      ga('send', 'pageview');\n
                    </script>\n
                </div>\n
GOOGLE;
    }
}


